//
//  RankCollectionViewCell.swift
//  ios_swift_demo1
//
//  Created by liutao on 2020/7/15.
//  Copyright © 2020 lt. All rights reserved.
//

import UIKit
import Kingfisher
import SnapKit

class TopCollectionViewCell: BaseCollectionViewCell {
    private lazy var imageView : UIImageView = {
        let imageview = UIImageView()
        imageview.contentMode = .scaleAspectFit
        return imageview
    }()
    
    private lazy var titleLabel : UILabel = {
        let label = UILabel()
        label.textAlignment = .center
        label.font = UIFont.systemFont(ofSize: 14)
        label.textColor = .black
        return label
    }()
    
    var model:LBUTopModel?{
        //属性观察器
        didSet {
            guard let model = model else { return }
            imageView.kf.setImage(urlString:model.cover)
            titleLabel.text = model.sortName
        }
    }
    
    
    override func setup() {
        layer.cornerRadius = 5
        layer.borderWidth = 1
        layer.borderColor = UIColor.lightGray.withAlphaComponent(0.5).cgColor
        layer.masksToBounds = true
        
        contentView.addSubview(imageView)
        imageView.snp.makeConstraints { (make) in
            make.left.right.top.equalToSuperview()
            make.height.equalTo(contentView.snp.width).multipliedBy(0.75)
        }
        
        contentView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { (make) in
            make.bottom.left.right.equalToSuperview()
            make.top.equalTo(imageView.snp.bottom)
        }
    }
}
